<?php


namespace app\backend\controller\v2;
use app\BaseController;
use think\facade\Filesystem;

class Upload extends BaseController
{
    //上传图片
    public function upload()
    {
        // 获取表单上传文件 例如上传了001.jpg
        $file = request()->file();
        if (empty($file))
            return errMsg(400,'请上传文件!');
        $k=array_keys($file);
        $saveName = Filesystem::disk('upload')->putFile('/uploads', $file[$k[0]]);
        if (!empty($saveName)) {
            $saveName = str_replace('\\', "/", $saveName);
            return sucessMsg(200, '上传成功', $saveName);
        }
    }
}